package arrays;

/**
 * @author pengfei.hpf
 * @date 2020/3/11
 * @verdion 1.0.0
 */
public class CanThreePartsEqualSum {

    public boolean canThreePartsEqualSum(int[] A) {
        if(A == null || A.length == 0){
            return false;
        }
        int sum = 0;
        for(int i: A){
            sum += i;
        }
        if(sum %3 != 0){
            return false;
        }
        sum = sum /3;
        int cur = 0;
        int count = 0;
        for(int i: A){
            cur += i;
            if(cur == sum){
                cur = 0;
                count ++;
            }
        }
        return cur == 0 && count >= 3;//TODO: 多余三个连续得零的情况有没有想过!!!!
    }
}
